--Account = {balance = 0}
--function Account.withdraw (v)
--   Account.balance = Account.balance - v
--end

--a, Account = Account, nil
--a.withdraw(100.00)  -- ERROR

Account = {balance = 0}
function Account.withdraw (self, v)
   self.balance = self.balance - v
end

a1 = Account; Account = nil
a1.withdraw(a1, 100.00) -- OK

a2 = {balance = 0, withdraw = Account.withdraw}
a2.withdraw(a2, 260.00)

-- this way is to hide `self` or `this` parameter
-- use colon operator
function Account:withdraw (v)
   self.balance = self.balance - v
end
-- call the method as
a:withdraw(100.00)

-- We can define a function with the dot syntax
-- and call it with the colon syntax, or vice- versa,
-- as long as we handle the extra parameter correctly
Account = {balance = 0,
		   withdraw = function (self, v)
			  self.balance = self.balance - v
		   end
}
function Account:deposit (v)
   self.balance = self.balance + v
end

Account.deposit(Account, 200.00)
Account:withdraw(100.00)
